package com.hanhai.zrb.mobile.controller;



import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hanhai.common.annotation.LoginNeedless;
import com.hanhai.common.web.controller.BaseController;
import com.hanhai.zrb.api.client.facade.ResourceMatchFacade;
import com.hanhai.zrb.mobile.result.BaseApiResult;
import com.hanhai.zrb.model.fund.vo.AppFundVo;
import com.hanhai.zrb.model.project.Project;
import com.hanhai.zrb.model.resourcematch.ResourceMatchTypeEnum;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;


@Controller
@RequestMapping("/resourceMacthApi")
public class ResourceMatchApiController extends BaseController{
	
	
	@Resource
	private ResourceMatchFacade resourceMatchFacade;


	
	
	@ResponseBody
	@ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") })
	@ApiOperation(value = "查询资金/项目匹配列表",  response = BaseApiResult.class, notes = "查询资金/项目匹配列表")
	@RequestMapping(value="/matchlist")
	public BaseApiResult matchlist(HttpServletRequest request,HttpServletResponse response,@RequestParam(value = "type", required = true) Integer type,@RequestParam(value = "bizid", required = true) Long bizid){
	    BaseApiResult result = new BaseApiResult();
	    if(ResourceMatchTypeEnum.FUND.getCode()==type){
		    List<Project> list = resourceMatchFacade.matchFundList(type,bizid);
	        result.setData(list);
	    }

	    if(ResourceMatchTypeEnum.PROJECT.getCode()==type){
        List<AppFundVo> list = resourceMatchFacade.matchProjectList(type,bizid);
        result.setData(list);
	    }
        
	    if(ResourceMatchTypeEnum.INTENTION_PROJECT.getCode()==type){
	        List<AppFundVo> list = resourceMatchFacade.matchProjectList(type,bizid);
	        result.setData(list);
		    }
	        
	    
	    if(ResourceMatchTypeEnum.INTENTION_FUND.getCode()==type){
		    List<Project> list = resourceMatchFacade.matchFundList(type,bizid);
	        result.setData(list);
		    }
	        
	    
		result.setRes(1);
		logger.info("user query fund list successed");
		return result;
	}
	
	
	
	
}
